home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
scav31.zip
/
SCAV30.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-09-10
|
14KB
|
557 lines
title scavenge Copyright (c) T. Jennings 1983
;downloaded from Simtel20's MSDOS.DISK-UTIL, 10 Sep 86
;
;****************************************
;* *
;* SCAVENGE *
;* *
;* Mark bad blocks on MSDOS *
;* as allocated in the FAT. *
;* *
;* T. Jennings 5 June 82 *
;* created 15 Sept. 82 *
;* Modified 14 December 1984 *
;* by David Gwillim *
;* *
;* *
;****************************************
;
;***********************************************************************
;** **
;** SCAV2XX was modified by David Gwillim to dynamically allocate **
;** memory to the variables BLKBUF and FATBUF when the program **
;** is started - this drastically reduced the size of the .COM file **
;** from 17K on disk to just over 1K, while still allowing the **
;** checking of disks with block sizes up to 16K Bytes. Also **
;** changed was the access to disk to determine its statistics **
;** (Number of Blocks, Blocksize etc) this is now done AFTER the **
;** pause command when the program is first started, permitting **
;** the program to be run with a single floppy drive. Code was **
;** also added to display the block size of the disk in bytes **
;** as part of the statistics, plus some alert tones for various **
;** parts of the program. **
;** **
;** I also added a more graceful exit than via ^C or Cntrl-Break **
;** as this would often leave you on the wrong drive if you aborted **
;** mid way through the block check and also would not give you the **
;** chance to update the FAT with any bad blocks found so far. **
;** **
;** A logical improvement to the program would be to add to the **
;** code so the program could report the names of the files which **
;** contain any bad blocks found, so the user could handle those **
;** files, or at least be aware that the data in them was corrupted. **
;** **
;** This is a very useful program and can give you great peace of **
;** mind if you own a hard disk and want to be sure that all is OK. **
;** If anyone takes a crack at doing the improvements I mentioned **
;** or finds and fixes any bugs, I would be delighted to hear of **
;** them. **
;** **
;** David Gwillim **
;** 1414 N. Catalina Street **
;** Los Angeles CA 90027 **
;** **
;************************************************************************
;
;Reads all sectors in logical MSDOS blocks
;and marks the file allocation tables such
;that the blocks are permanently allocated
;where CHKDSK will not deallocate them.
;
;
;This version works on any 2.xx MSDOS or
;PCDOS, on any media type, fixed or removable.
;One (major) limitation: it will not map out
;blocks that are already allocated to a file;
;it will say "block used", but won't tell you
;which file it is in.
;
;If SCAVENGE finds any bad blocks, it will ask
;you whether or not you want the disk updated.
;You can safely run it just to see if the disk
;is OK.
;
;MASM, LINK, then EXE2BIN this to make a COM
;file. It will not run as an EXE file. NOTE:
;LINK will give you a 'Warning: no STACK
;segment' error: ignore it.
;
cr equ 0dh
lf equ 0ah
;Beep procedure count values
;---------------------------
;To generate a given freqency note out of the speaker with the Beep procedure
;on the PC using Channel 2 of the 8253 timer, the channel 2 count register
;must be loaded with a value such that the 8253 input clock frequency
;(1.19318 MHz) divided by the count figure equals the audio frequency.
f176Hz equ 6779 ; 176 Hz count value
f352Hz equ 3390 ; 352 Hz count value
f704Hz equ 1695 ; 704 Hz count value
f1408Hz equ 847 ; 1408 Hz count value
page
cgroup group code
code segment byte public 'code'
assume cs:cgroup,ds:cgroup,ss:cgroup
;
;MSDOS page 0 stuff.
;
org 5ch
tfcb label byte
org 80h
tbuff label byte
org 100h
scavenge:
jmp start
;
;Disk parameters:
;
blkcnt dw (?) ;blocks this disk
blksize dw (?) ;sectors per block
secsize dw (?) ;phys. sector size
badcnt dw (?) ;# bad blocks found
newbad dw (?) ;new bad ones
block dw (?) ;current block
sector dw (?) ;sector to read
disk db (?) ;selected disk
curdsk db (?) ;current disk.
fatsec dw (?) ;1st FAT sector,
fatcnt dw (?) ;FAT sec count.
dw 128 dup (?)
stack dw (?) ;what else
page
;
;Say who we are, describe the disk we are
;about to fix, ask to continue or abort.
;
start: mov ax,cs
mov ds,ax
cli ;Disable interrupts while we move stack
mov ss,ax
mov sp,offset stack
sti ;Re-enable interrupts
mov dx,offset signon
call putstr
mov bx,f176Hz ;Alert user audibly
call beep
mov bx,f704Hz
call beep
mov bx,f352Hz
call beep
mov bx,f1408Hz
call beep
call ina
or al,20h ;Make character lower case
cmp al,'q' ;Quit?
jne st0
mov dx,offset abort
call putstr
int 20h
st0: call setup ;get disk stuff
jnc st1
call putstr
int 20h ;error.
st1: call liststat ;describe dsk
;
;Find all the bad blocks, if any, display them,
;ask if we should update the FAT. If so, write
;it out.
;
mov dx,offset crlf
call putstr
call findbad ;map bad,
call listbad ;list them,
cmp newbad,0 ;if new bad
je st2 ;blocks...
mov dx,offset updstr ;ask if we
call putstr ;should update
call ina
and al,5fh
cmp al,'Y'
jne st1A
mov al,disk ;write out the
mov dx,fatsec ;FAT,
mov cx,fatcnt
mov bx,offset fatbuf
int 26h
pop ax ;pop flags
mov dx,offset update
call putstr
jmp st2
st1A: mov dx,offset noupdte
call putstr
st2: mov al,curdsk ;reselect the
call seldsk ;original disk
int 20h
signon db cr,lf,9,'*********************************************'
db cr,lf,9,'* DOS 2.xx Bad Sector Mapper - Version 3.00 *'
db cr,lf,9,'* Updated by David Gwillim 18 December 1984 *'
db cr,lf,9,'* Original program by T. Jennings 5 June 83 *'
db cr,lf,9,'*********************************************'
db cr,lf,lf
db 'Type Q to abort at any time, any other key to continue ...'
db cr,lf,'$'
updstr db cr,lf,lf,'Want the disk updated? [y,n] $'
noupdte db cr,lf,lf,'FAT not updated',cr,lf,'$'
update db cr,lf,lf,'FAT updated',cr,lf,'$'
crlf db cr,lf,'$'
page
;
;Get the data on the specified disk. Return
;carry if no drive specified. Returns ES:DI
;pointing to the FAT for the selected drive.
;
setup: call initdsk ;reset dsk sys,
call getdsk ;get current,
mov curdsk,al ;save it,
mov al,tfcb ;make sure a
cmp al,0 ;new one spec'd
stc ;quit if none,
mov dx,offset strstr
jz gd1
dec al ;make 0-N,
mov disk,al
call seldsk ;select,
push ds ;save local DS,
mov ah,1bh
int 21h
pop ds
mov blkcnt,dx ;save # blocks,
mov secsize,cx ;sector size,
;th mov ah,0
xor ah,ah ;th
mov blksize,ax ;secs/block.
push ds ;now get the
mov dl,disk
inc dl ;drive 1=A, b=2
mov ah,32h ;FAT,
int 21h ;get the DPB,
mov cx,[bx+15] ;CX= sec count,
;th mov ch,0
xor ch,ch ;th
mov dx,[bx+6] ;DX= 1st sec,
pop ds
mov fatcnt,cx ;save both,
mov fatsec,dx
mov al,disk ;AL= drive #,
mov bx,offset fatbuf ;DS:BX= buffer
int 25h ;read the FAT,
pop ax ;pop flags
mov dx,offset bscstr
gd1: ret
strstr db cr,lf,'Must specify a disk drive.$'
bscstr db cr,lf,'Bad FAT sector: disk not useable.$'
page
;
;Read the entire disk looking for bad blocks.
;When one is found, go mark it as an allocated
;bad block.
;
findbad:
mov block,0 ;1st block,
mo